fn main():void! {
    // list index
    var list = [1, 2, 3]
    var item = list[5] catch err {
        print('catch vec index err=', err.msg(), '\n')
        0
    }
    println(item)

    any a1 = 1 as i8
    var i1 = a1 as i16 catch err1 {
        print('catch type assert err=', err1.msg(), '\n')
        0
    }

    // 基于 struct fn 和 struct list 测试一下简单的链式调用
    type test = struct {
        [i8] list
        fn(int,int):int! div
    }

    // 结构体实例化
    var foo = test{
        list: [1, 2, 3, 4, 5],
        div: fn(int a, int b):int! {
            if b == 0 {
                throw errorf('divisor cannot zero')
            }
            return a / b
        },
    }

    // 正常访问
    print(foo.list[1], foo.div(10, 5), '\n')

    // 异常处理
    var a2 = foo.list[8] catch err2 {
        print('chain access vec err=', err2.msg(), '\n')
        0
    }

    var a3 = foo.div(10, 0) catch err3 {
        print("chain access call err=", err3.msg(), '\n')
        0
    }

    println('hello world')
}